home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_ORBit.idb / usr / freeware / include / IIOP / giop-msg-buffer.h.z / giop-msg-buffer.h
Encoding:
C/C++ Source or Header  |  1999-07-16  |  6.0 KB  |  229 lines

  1. #ifndef GIOP_MSG_BUFFER_H
  2. #define GIOP_MSG_BUFFER_H 1
  3.  
  4. #include "IIOP.h"
  5. /* For struct iovec */
  6. #include <sys/uio.h>
  7.  
  8. typedef enum {
  9.   GIOP_REQUEST,
  10.   GIOP_REPLY,
  11.   GIOP_CANCELREQUEST,
  12.   GIOP_LOCATEREQUEST,
  13.   GIOP_LOCATEREPLY,
  14.   GIOP_CLOSECONNECTION,
  15.   GIOP_MESSAGEERROR,
  16.   GIOP_FRAGMENT
  17. } GIOPMsgType;
  18.  
  19. /* GIOP message header */
  20. typedef struct _GIOPMessageHeader {
  21.   GIOP_char magic[4];
  22.   GIOP_char GIOP_version[2];
  23.   GIOP_octet flags;
  24.  
  25.   /*
  26.    * We should really use GIOPMsgType
  27.    * but that enum winds up being an int...
  28.    */
  29.   GIOP_octet message_type;
  30.  
  31.   GIOP_unsigned_long message_size;
  32. } GIOPMessageHeader;
  33.  
  34. #define GIOP_MESSAGE_BUFFER(x) ((GIOPMessageBuffer *)x)
  35. typedef struct _GIOPMessageBuffer
  36. {
  37.   /* The connection that this message will go out over... */
  38.   GIOPConnection *connection; 
  39.                  
  40.   GArray *iovecs;
  41.   GIOPMessageHeader message_header;
  42. } GIOPMessageBuffer;
  43.  
  44. #include "../orb/iop.h"
  45.  
  46. /* GIOP_REQUEST header */
  47. typedef enum {
  48.   GIOP_NO_EXCEPTION,
  49.   GIOP_USER_EXCEPTION,
  50.   GIOP_SYSTEM_EXCEPTION,
  51.   GIOP_LOCATION_FORWARD
  52. } GIOPReplyStatusType;
  53.  
  54. typedef struct _GIOPMessageRequest {
  55.   IOP_ServiceContextList service_context;
  56.   GIOP_unsigned_long request_id;
  57.   GIOP_boolean response_expected;
  58.   CORBA_sequence_octet object_key;
  59.   CORBA_char *operation;
  60.   CORBA_Principal requesting_principal;
  61. } GIOPMessageRequest;
  62.  
  63. typedef struct _GIOPMessageReply {
  64.   IOP_ServiceContextList service_context;
  65.   GIOP_unsigned_long request_id;
  66.   GIOPReplyStatusType reply_status;
  67. } GIOPMessageReply;
  68.  
  69. typedef struct _GIOPMessageCancelRequest {
  70.   GIOP_unsigned_long request_id;
  71. } GIOPMessageCancelRequest;
  72.  
  73. typedef struct _GIOPMessageLocateRequest {
  74.   GIOP_unsigned_long request_id;
  75.   CORBA_sequence_octet object_key;
  76. } GIOPMessageLocateRequest;
  77.  
  78. typedef enum {
  79.   GIOP_UNKNOWN_OBJECT,
  80.   GIOP_OBJECT_HERE,
  81.   GIOP_OBJECT_FORWARD
  82. } GIOPLocateStatusType;
  83.  
  84. typedef struct _GIOPMessageLocateReply {
  85.   GIOP_unsigned_long request_id;
  86.   GIOPLocateStatusType locate_status;
  87. } GIOPMessageLocateReply;
  88.  
  89. typedef struct _GIOPMessage
  90. {
  91.   union {
  92.     GIOPMessageRequest request;
  93.     GIOPMessageReply reply;
  94.     GIOPMessageCancelRequest cancel_request;
  95.     GIOPMessageLocateRequest locate_request;
  96.     GIOPMessageLocateReply locate_reply;
  97.   } u;
  98. } GIOPMessage;
  99.  
  100. typedef enum {
  101.   GIOP_MSG_READING_HEADER,
  102.   GIOP_MSG_READING_BODY,
  103.   GIOP_MSG_READY
  104. } GIOPMessageBufferState;
  105.  
  106. #define GIOP_SEND_BUFFER(x) ((GIOPSendBuffer *)x)
  107. typedef struct _GIOPSendBuffer
  108. {
  109.   GIOPMessageBuffer message_buffer;
  110.  
  111.   gpointer indirect;
  112.  
  113.   GMemChunk *indirects; /* Request buffers only (at present) */
  114.   gulong indirect_used;
  115.  
  116.   GIOPMessage message;
  117.   CORBA_unsigned_long scontext_tmp;
  118. } GIOPSendBuffer;
  119.  
  120. #define GIOP_RECV_BUFFER(x) ((GIOPRecvBuffer *)x)
  121. typedef struct _GIOPRecvBuffer
  122. {
  123.   GIOPMessageBuffer message_buffer;
  124.   GIOPMessage message;
  125.  
  126.   gpointer message_body;
  127.   gpointer cur;
  128.  
  129.   void (*decoder)(gpointer dest, gpointer src, gulong len);
  130.  
  131.   GIOPMessageBufferState state;
  132.   gint left_to_read;
  133. } GIOPRecvBuffer;
  134.  
  135. /* This function needs to be called before useful things happen */
  136. void giop_message_buffer_init(void);
  137.  
  138. gint giop_send_buffer_write(GIOPSendBuffer *request_buffer);
  139.  
  140. void 
  141. giop_message_buffer_append_mem_a(GIOPMessageBuffer *request_buffer,
  142.                  gconstpointer mem_region,
  143.                  gulong mem_region_length);
  144. void 
  145. giop_message_buffer_append_mem(GIOPMessageBuffer *request_buffer,
  146.                    gconstpointer mem_region,
  147.                    gulong mem_region_length);
  148.  
  149. /*
  150.  * This copies the value into a request-specific buffer before
  151.  * adding it to the list
  152.  */
  153. gpointer
  154. giop_send_buffer_append_mem_indirect_a(GIOPSendBuffer *request_buffer,
  155.                        gconstpointer mem_region,
  156.                        gulong mem_region_length);
  157. gpointer
  158. giop_send_buffer_append_mem_indirect(GIOPSendBuffer *request_buffer,
  159.                      gconstpointer mem_region,
  160.                      gulong mem_region_length);
  161.  
  162. GIOPSendBuffer *
  163. giop_send_request_buffer_use(GIOPConnection *connection,
  164.                  const IOP_ServiceContextList *service_context,
  165.                  GIOP_unsigned_long request_id,
  166.                  GIOP_boolean response_expected,
  167.                  const struct iovec *object_key_vec,
  168.                  const struct iovec *operation_vec,
  169.                  const struct iovec *principal_vec);
  170. GIOPSendBuffer *
  171. giop_send_reply_buffer_use(GIOPConnection *connection,
  172.                const IOP_ServiceContextList *service_context,
  173.                GIOP_unsigned_long request_id,
  174.                GIOPReplyStatusType reply_status);
  175. GIOPSendBuffer *
  176. giop_send_locate_request_buffer_use(GIOPConnection *connection,
  177.                  GIOP_unsigned_long request_id,
  178.                  const struct iovec *object_key_vec);
  179. GIOPSendBuffer *
  180. giop_send_locate_reply_buffer_use(GIOPConnection *connection,
  181.                GIOP_unsigned_long request_id,
  182.                GIOPLocateStatusType reply_status);
  183.  
  184. void giop_send_buffer_unuse(GIOPSendBuffer *send_buffer);
  185.  
  186. GIOP_unsigned_long giop_get_request_id(void);
  187.  
  188. GIOPRecvBuffer *
  189. giop_recv_reply_buffer_use(GIOP_unsigned_long request_id,
  190.                gboolean block_for_reply);
  191. GIOPRecvBuffer *
  192. giop_recv_reply_buffer_use_2(GIOPConnection *request_cnx,
  193.                  GIOP_unsigned_long request_id,
  194.                  gboolean block_for_reply);
  195.  
  196. /* For DII - hands back the first received request matching an id on the list */
  197. GIOPRecvBuffer *
  198. giop_recv_reply_buffer_use_multiple(GArray *request_ids,
  199.                     gboolean block_for_reply);
  200. GIOPRecvBuffer *
  201. giop_recv_reply_buffer_use_multiple_2(GIOPConnection *request_cnx,
  202.                       GArray *request_ids,
  203.                       gboolean block_for_reply);
  204.  
  205. GIOPRecvBuffer *
  206. giop_recv_locate_reply_buffer_use(GIOP_unsigned_long request_id,
  207.                   gboolean block_for_reply);
  208.  
  209. /*
  210.  * For server-side use. It's the responsibility of the caller to do
  211.  * any select()ion desired
  212.  */
  213. GIOPRecvBuffer *
  214. giop_recv_message_buffer_use(GIOPConnection *connection);
  215.  
  216. void giop_recv_buffer_unuse(GIOPRecvBuffer *buffer);
  217.  
  218. /*
  219.  * This is used for sending (and recving, if we ever
  220.  *  get zero-copy receives implemented) alignment bytes
  221.  */ 
  222. extern char giop_scratch_space[2048];
  223. gulong giop_message_buffer_do_alignment(GIOPMessageBuffer *buffer,
  224.                     gulong align_for);
  225.  
  226. #define giop_msg_conversion_needed(msgbuf) (conversion_needed(GIOP_MESSAGE_BUFFER(msgbuf)->message_header.flags & 1))
  227.  
  228. #endif /* GIOP_MSG_BUFFER_H */
  229.